/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
  CCell, Cell, RCell, Table, TableBody, TableHead, TableRow, Text,
} from "customize-easy-ui-component";
import {CCellUnit, RepLink} from "../../common/base";
import {useOmnipotentPref, } from "../../hook/useOmnipotentPref";
import {item附件压力, item附件焊接, item附件紧急} from "./editorAcces";
import {TailMenRowIspCheck} from "../../contain/rarelyVary";


//【注意】结果列，存储的变量是[]?。
const tailRender=(orc: any, name: string,lix:number)=><>
  <CCell>{orc?.[name]?.r??'／'}</CCell>
  <CCell>{orc?.[name]?.m??'／'}</CCell>
</>;

export const 安全附件检验= ({theme, orc, rep} :{theme: any, orc:any, rep:any}
) => {
  const [renderPress]=useOmnipotentPref({orc, config:item附件压力,
         tailRender, pcols:2, noNo:true, unitCel:false, xmcol:2});
      //这才是第一行的 renderHj1[0]   const [renderHj1,...otherLine]=
  const [renderHj1,_2,...moreLines]=useOmnipotentPref({orc, config:item附件焊接,
              tailRender, pcols:2, noNo:true, unitCel:false, xmcol:2,split:[0,1]});
  return <>
    <div css={{"@media print": {paddingBottom: '3.5rem', pageBreakInside: 'avoid'}} }>
      <Text id='AdditionalTest' variant="h2" css={{textAlign: 'center', marginTop: '1rem',
      }}>附件检验报告</Text>
      <div css={{display: 'flex', justifyContent: 'space-between'}}>
        <Text></Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table fixed={ ["3%","9%","%","29%","12%","22%"] } css={{borderCollapse: 'collapse', "@media print": {marginTop: '-3.5rem'}}} tight  miniw={800}>
      <TableHead>
        <TableRow>
          <CCell><Text css={{fontSize:'0.6rem'}}>序号</Text></CCell><CCell colSpan={3}>检 验 项 目</CCell><CCell>检验结果</CCell><CCell>备注</CCell>
        </TableRow>
      </TableHead>
      <TableBody>
        <RepLink rep={rep} tag={'Attachments'}>
          { renderHj1 }
          <TableRow>
            <RCell>型号/数量：</RCell>
            { (orc?.紧型数?.x || orc?.紧型数?.s) ?
                <CCellUnit unit={'个'}>{orc?.紧型数?.x} ／ {orc?.紧型数?.s}</CCellUnit>
                :
                <CCell>／</CCell>
            }
            <CCell>{orc?.紧型数?.xr??'／'}</CCell><CCell>{orc?.紧型数?.xm??'／'}</CCell>
          </TableRow>
          { moreLines }

          {item附件紧急.map(([name, title]: any, i: number) => {
            return (<React.Fragment key={i}>
              <TableRow>
                <CCell rowSpan={3}>{i+2}</CCell><CCell rowSpan={3}>{title}</CCell><CCell colSpan={2}>外观完好，无破损、泄漏</CCell>
                <CCell>{orc?.[name]?.r??'／'}</CCell><CCell>{orc?.[name]?.m??'／'}</CCell>
              </TableRow>
              <TableRow>
                <RCell>型号/数量：</RCell>
                { (orc?.[name]?.x || orc?.[name]?.s) ?
                      <CCellUnit unit={'个'}>{orc?.[name]?.x} ／ {orc?.[name]?.s}</CCellUnit>
                    :
                    <CCell>／</CCell>
                }
                <CCell>{orc?.[name]?.xr??'／'}</CCell><CCell>{orc?.[name]?.xm??'／'}</CCell>
              </TableRow>
              <TableRow>
                <RCell>校验有效期至：</RCell><CCell>{orc?.[name]?.V??'／'}</CCell>
                <CCell>{orc?.[name]?.R??'／'}</CCell><CCell>{orc?.[name]?.M??'／'}</CCell>
              </TableRow>
            </React.Fragment>);
          })}

          <TableRow>
            <CCell rowSpan={3}>7</CCell><CCell rowSpan={3}>导静电装置</CCell><CCell colSpan={2}>导静电装置的接地线与车架之间电阻值≤5Ω；</CCell>
            <CCell>{orc?.导静电?.r??'／'}</CCell><CCell>{orc?.导静电?.m??'／'}</CCell>
          </TableRow>
          <TableRow>
            <RCell>实测电阻值：</RCell><CCellUnit unit={'Ω'}>{orc?.导静电?.x}</CCellUnit>
            <CCell>{orc?.导静电?.xr??'／'}</CCell><CCell>{orc?.导静电?.xm??'／'}</CCell>
          </TableRow>
          <TableRow>
            <RCell>检测仪器编号：</RCell><CCell>{orc?.导静电?.V}</CCell>
            <CCell>{orc?.导静电?.R??'／'}</CCell><CCell>{orc?.导静电?.M??'／'}</CCell>
          </TableRow>
          <TableRow>
            <CCell split rowSpan={3}>8</CCell><CCell split rowSpan={3}>装卸阀门</CCell><CCell colSpan={2}>外观完好，无破损，操作自如，关闭状态下无泄漏</CCell>
            <CCell>{orc?.装卸阀?.r??'／'}</CCell><CCell>{orc?.装卸阀?.m??'／'}</CCell>
          </TableRow>
          <TableRow>
            <RCell>数量：</RCell><CCellUnit unit={'个'}>{orc?.装卸阀?.x??'／'}</CCellUnit>
            <CCell>{orc?.装卸阀?.xr??'／'}</CCell><CCell>{orc?.装卸阀?.xm??'／'}</CCell>
          </TableRow>
          <TableRow>
            <Cell colSpan={2}>充装易燃介质的罐体，阀门材质应为不产生火花的铜、铝合金或 不锈钢材质；充装毒性程度为极度、高度危害介质和强腐蚀介质 的罐体，阀门公称压力应不低于1.6 MPa；</Cell>
            <CCell>{orc?.装卸阀?.R??'／'}</CCell><CCell>{orc?.装卸阀?.M??'／'}</CCell>
          </TableRow>

          {renderPress}
          <TableRow>
            <CCell>结果</CCell>
            <Cell colSpan={5}><div css={{minHeight: '2rem',whiteSpace:'pre-wrap'
            }}>{orc.附件结果??'／'}</div></Cell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    <TailMenRowIspCheck orc={orc} rep={rep} href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/ProjectList#ProjectList`}>
    </TailMenRowIspCheck>
  </>;
};

/* 【特别报错】   literal text must be wrapped in <></> tag or Components
</TableRow>
  ,        <TableRow>
* */